<?php

class CommentTable extends Doctrine_Table
{
  public function findByObject($objectType, $objectId)
  {
    $q = Doctrine_Query::create()
            ->select('c.*')
            ->from('Comment c')
            ->where('c.object_type=? AND c.object_id=?', array($objectType, $objectId))
            ->orderBy('created_at ASC');
    return $q->execute();
  }
  
  public function getComment($ipAddress, $objectType, $objectId, $body)
  {
    $q = Doctrine_Query::create()
            ->select('c.*')
            ->from('Comment c')
            ->where('c.ip_address=? AND c.object_type=? AND c.object_id=? AND c.text=?', array($ipAddress, $objectType, $objectId, $body));
    return $q->fetchOne();
  }

}